<template>
    <view class="page" v-if="pageLoad">
        <z-paging ref="paging" v-model="list" :refresher-end-bounce-enabled="false" :auto-show-back-to-top="true" :default-page-size="100000" @query="queryList">
            <view class="list">
                <view class="list-item" v-for="item in list" @click="routerPush(`/pages/house/detail?id=${item.id}`)">
                    <view class="text-15 text-bold">{{ item.orderName }}</view>
                    <view class="flex justify-between mt-8 pt-8 translate-box">
                        <view class="text-14 error pr-5">
                            <text>{{ item.price }}元</text>
                        </view>
                        <view class="gray9">{{ item.payTime }}</view>
                    </view>
                </view>
            </view>
        </z-paging>
    </view>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { getOrderList } from '@/api/order';
import { toast, routerPush } from '@/assets/js/utils';

const pageLoad = ref(false);
onLoad(options => {
    pageLoad.value = true;
});

//列表相关
const paging: any = ref(null);
const list: any = ref([]);
const queryList = async (pageNo: number, pageize: number) => {
    let data: any = {};
    data.lastId = pageNo > 1 ? list.value[list.value.length - 1].id : null;
    let [result, err] = await getOrderList(data);
    if (err) {
        paging.value.complete(false);
    } else {
        paging.value.complete(result);
    }
};
</script>

<style lang="scss" scoped>
.page {
    width: 100vw;
    min-height: 100vh;
    background: #f6f6f6;
    .list {
        margin: 32rpx;
        .list-item {
            background-color: #fff;
            border-radius: 32rpx;
            padding: 32rpx 32rpx;
            margin-bottom: 32rpx;
        }
    }
}
.translate-box {
    border-top: 1rpx dashed #ddd;
}
</style>
